package com.ymx.darling.type;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ByteObjectArrayHandler implements TypeHandler<Byte[]> {
    @Override
    public Byte[] getResult(ResultSet resultSet, int columIndex) throws SQLException {
        byte[] bytes = resultSet.getBytes(columIndex);
        return bytes == null ? null : ByteArrayUtil.convertToObjectArray(bytes);
    }

    @Override
    public void setParameter(PreparedStatement statement, Byte[] value, int index) throws SQLException {
        statement.setBytes(index, ByteArrayUtil.convertToPrimitiveArray(value));
    }
}